package com.nbsaas.boot.app.rest.convert;

import com.nbsaas.boot.app.data.entity.AppRoleMenu;
import com.nbsaas.boot.app.api.domain.request.AppRoleMenuRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.app.data.entity.App;
            import com.nbsaas.boot.app.data.entity.AppRole;
            import com.nbsaas.boot.app.data.entity.AppMenu;

/**
* 角色请求对象转换成实体对象
*/

public class AppRoleMenuEntityConvert  implements Converter<AppRoleMenu, AppRoleMenuRequest> {

    @Override
    public AppRoleMenu convert(AppRoleMenuRequest source) {
        AppRoleMenu result = new AppRoleMenu();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getApp()!=null){
                    App app =new App();
                    app.setId(source.getApp());
                    result.setApp(app);
                    }
                    if(source.getRole()!=null){
                    AppRole role =new AppRole();
                    role.setId(source.getRole());
                    result.setRole(role);
                    }
                    if(source.getMenu()!=null){
                    AppMenu menu =new AppMenu();
                    menu.setId(source.getMenu());
                    result.setMenu(menu);
                    }
        return result;
    }
}

